package Flink.function;

import Flink.bean.WaterSensor;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.util.Collector;

public class MyFlatMap implements FlatMapFunction<WaterSensor, String> {

    @Override
    public void flatMap(WaterSensor value, Collector<String> out) throws Exception {
        if ("sensor_1".equals(value.getId())) {
            out.collect(String.valueOf(value.vc));
        } else if ("sensor_2".equals(value.getId())) {
            out.collect(String.valueOf(value.ts));
            out.collect(String.valueOf(value.vc));
        }
    }
}
